package com.ww.sound_emission.controller;

import com.ww.sound_emission.domain.Likes;
import com.ww.sound_emission.service.LikesService;
import com.ww.sound_emission.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/likes")
public class LikeController {

    @Autowired
    private LikesService likeService;

    // 添加点赞
    @PostMapping
    public Result<String> addLike(@RequestBody Likes like) {
        likeService.save(like);
        return Result.success("点赞成功");
    }

    // 取消点赞
    @DeleteMapping("/{id}")
    public Result<String> deleteLike(@PathVariable Long id) {
        likeService.removeById(id);
        return Result.success("取消点赞成功");
    }
}